cmake_minimum_required(VERSION 3.5)

project(orocos_kdl_example)

# 条件逻辑示例
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
    message(STATUS "Building in Debug mode")
else()
    message(STATUS "Building in Release mode")
endif()

# 设置Eigen3路径
set(Eigen3_DIR "${PROJECT_SOURCE_DIR}/../3rdparty/eigen-340/_install_x86_64/share/eigen3/cmake")
message(STATUS "** Eigen3_DIR: ${Eigen3_DIR}")
set(orocos_kdl_DIR "${PROJECT_SOURCE_DIR}/../3rdparty/orocos-150/_install_x86_full/share/orocos_kdl/cmake")
message(STATUS "** orocos_kdl_DIR: ${orocos_kdl_DIR}")
message(STATUS "** PROJECT_SOURCE_DIR: ${PROJECT_SOURCE_DIR}")

# 查找依赖包
# find_package(orocos_kdl REQUIRED)
find_package(orocos_kdl)
if(orocos_kdl_FOUND)
    message(STATUS "Found orocos_kdl:")
    message(STATUS "  Version: ${orocos_kdl_VERSION}")
    message(STATUS "  Include directories: ${orocos_kdl_INCLUDE_DIRS}")
    message(STATUS "  Library directories: ${orocos_kdl_LIBRARY_DIRS}")
    message(STATUS "  Libraries: ${orocos_kdl_LIBRARIES}")
else()
    message(FATAL_ERROR "Error: orocos_kdl not found")
endif()

# find_package(Eigen3 REQUIRED)
find_package(Eigen3)
if(Eigen3_FOUND)
    message(STATUS "Found Eigen3:")
    message(STATUS "  Version: ${Eigen3_VERSION}")
    message(STATUS "  Include directories: ${Eigen3_INCLUDE_DIR}")
    # message(STATUS "  Library directories: ${Eigen3_LIBRARY_DIRS}")
    # message(STATUS "  Libraries: ${Eigen3_LIBRARIES}")
else()
    message(FATAL_ERROR "Error: Eigen3 not found")
endif()

# 包含头文件目录
# include_directories(${orocos_kdl_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIRS})

# 添加可执行文件 orocos_example_1
add_executable(orocos_example_1 main_orocos_1.cpp)
target_include_directories(orocos_example_1 PRIVATE
    ${orocos_kdl_INCLUDE_DIRS}
)
target_link_libraries(orocos_example_1
    Eigen3::Eigen
    orocos-kdl    
    orocos-kdl-models
)

# 添加可执行文件 orocos_example_2
add_executable(orocos_example_2 main_orocos_2.cpp)
target_include_directories(orocos_example_2 PRIVATE
    ${orocos_kdl_INCLUDE_DIRS}  # 可以这样写
)
target_link_libraries(orocos_example_2
    Eigen3::Eigen
    # orocos-kdl    
    ${orocos_kdl_LIBRARIES}     # 可以这样写
    orocos-kdl-models
)